﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rabbit.Utils;
using Rabbit.Modal;
namespace Rabbit.BusinessLogicLayer
{
    internal class WrappedJsonHelper
    {
        public static T Deserialize<T>(string json)
        {
            try
            {
               return  JsonHelper.Deserialize<T>(json);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex); 
                try
                {
                    HashObject obj  = JsonHelper.Deserialize<HashObject>(json);
                    throw new PublishAPICallTooFrequentException();
                }
                catch
                {
                    throw;
                }
            }
        }

        public static string Serialize<T>(T obj)
        {
            try
            {
                return JsonHelper.Serialize<T>(obj);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
